package com.etop.service;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.etop.dao.PermissionDao;
import com.etop.pojo.Permission;


/**
 * 类名:PermissionService
 * 描述:权限服务和DAO对接
 * @author Administrator
 *
 */
@SuppressWarnings("serial")
@Service
public class PermissionService implements Serializable {
	@Resource
    private PermissionDao permissionDao;
	
	public List<Permission> findAll(){
		return permissionDao.find("from Permission");
	}
	public void savePermission(Permission permission){
		permissionDao.save(permission);
	}
	public Permission findPermissionById(int id){
		Map<String,Object> params=new HashMap<String,Object>();
		params.put("id", id);
		return (Permission) permissionDao.findUniqueResult("from Permission where id=:id", params);
	}
	public void updatePermission(Permission permission){
		permissionDao.saveOrUpdate(permission);
	}
	public void deletePermission(int id){
		permissionDao.deleteById(id);
	}
	public String getNameById(int id){
		Map<String,Object> params=new HashMap<String,Object>();
		params.put("id", id);
		Permission permission=(Permission) permissionDao.findUniqueResult("from Permission where id=:id", params);
		return permission.getPermissionname();
		
	}
}
